<include file='Common:header'/>
<!-- file='板板文件夹:模板文件名' -->
	<title>{$Think.config.WEBNAME}-修改个人资料</title>
	<link rel="stylesheet" href="__PUBLIC__/Theme/default/Css/nav.css" />
	<link rel="stylesheet" href="__PUBLIC__/Theme/default/Css/edit.css" />
    <link rel="stylesheet" href="__PUBLIC__/Uploadify/uploadify.css"/>
	<script type="text/javascript" src='__PUBLIC__/Js/jquery-1.7.2.min.js'></script>
    <!-- 导航js -->
	<script type="text/javascript" src='__PUBLIC__/Js/nav.js'></script>
    <!-- 中国省市json变量： -->
    <script type='text/javascript' src='__PUBLIC__/Js/city.js'></script>
    <!-- 页面主逻辑js -->
    <script type='text/javascript' src='__PUBLIC__/Js/edit.js'></script>
    <!-- jquery上传和验证插件 -->
    <script type="text/javascript" src='__PUBLIC__/Uploadify/jquery.uploadify.min.js'></script>
    <js file='__PUBLIC__/Js/jquery-validate.js'/>
<!--==========顶部固定导行条==========-->
    <include file='Common:nav'/>

<!--==========内容主体==========-->
    <div style='height:60px;opcity:10'></div>
    <div class="main">
    <!--=====左侧=====-->
        <include file='Common:left'/>
    <!--=====右侧=====-->
        <div id='right'>
            <ul id='sel-edit'>
            <!-- 选项卡切换按纽 -->
                <li class='edit-cur'>基本信息</li>
                <li>修改头像</li>
                <li>修改密码</li>
            </ul>
            <div class='form'>
            <!-- 提交用户信息 -->
                <form action="{:U('editBasic')}" method='post' name="editBasic">
                    <p>
                        <label for=""><span class='red'>*</span>昵称：</label>
                        <input type="text" name='nickname' value='{$user.username}' class='input'/>
                    </p>
                    <p>
                        <label for="">真实名称：</label>
                        <input type="text" name='truename' value='{$user.truename}' class='input'/>
                    </p>
                    <p>
                        <label for="">账号：</label>
                        <input type="text"  value='{$account}' class='input' disabled="disabled"/>
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>性别：</label>
                        <input type="radio" name='sex' value='1' <if condition='$user["sex"] == "男"'>checked='checked'</if>/>&nbsp;男&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="radio" name='sex' value='2' <if condition='$user["sex"] == "女"'>checked='checked'</if>/>&nbsp;女
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>所在地：</label>
                        <select name="province" id="">
                            <option value="">请选择</option>
                        </select>&nbsp;&nbsp;&nbsp;&nbsp;
                        <select name="city">
                            <option value="">请选择</option>
                        </select>
                    </p>
                    <p>
                        <label for="">星座：</label>
                        <select name="night" id="">
                            <option value="">请选择</option>
                            <option value="白羊座">白羊座</option>
                            <option value="金牛座">金牛座</option>
                            <option value="双子座">双子座</option>
                            <option value="巨蟹座">巨蟹座</option>
                            <option value="狮子座">狮子座</option>
                            <option value="处女座">处女座</option>
                            <option value="天秤座">天秤座</option>
                            <option value="天蝎座">天蝎座</option>
                            <option value="射手座">射手座</option>
                            <option value="魔羯座">魔羯座</option>
                            <option value="水瓶座">水瓶座</option>
                            <option value="双鱼座">双鱼座</option>
                        </select>
                    </p>
                    <p>
                        <label for="" class='intro'>一句话介绍自己：</label>
                        <textarea name="intro">{$user.intro}</textarea>
                    </p>
                    <p>
                        <input type="submit" value='保存修改' class='edit-sub'/>
                    </p>
                </form>
            </div>
            <div class='form hidden'>
                <form action="{:U('editFace')}" method='post'>
                    <div class='edit-face'>
                        <img id="preview" src="
                        <if condition='$user["face180"]'>
                           {$user.face180}
                        <else/>
                            __PUBLIC__/Images/noface.gif
                        </if>" width='180' height='180' id='face-img'/>
                        <p>
                        <!-- 文件上传 -->
                            <input type="file"  id='face'/>
                        </p>
                        <p>
                        <!-- 这三个隐藏域是用来存放头像服务器路径的 -->
                            <input type="hidden" name='face180' value=''/>
                            <input type="hidden" name='face80' value=''/>
                            <input type="hidden" name='face50' value=''/>
                            <input type="submit" value='保存修改' class='edit-sub'/>
                        </p>
                    </div>
                </form>
            </div>
            <div class='form hidden'>
                <form action="{:U('editPwd')}" method='post' name='editPwd'>
                    <p class='account'>登录邮箱：<span>admin@admin.com</span></p>
                    <p>
                        <label for=""><span class='red'>*</span>旧密码：</label>
                        <input type="password" name='old' class='input'/>
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>新密码：</label>
                        <input type="password" name='new' class='input' id='new'/>
                    </p>
                    <p>
                        <label for=""><span class='red'>*</span>确认密码：</label>
                        <input type="password" name='newed' class='input'/>
                    </p>
                    <p>
                        <input type="submit" value='确认修改' class='edit-sub'/>
                    </p>
                </form>
            </div>
        </div>
    </div>
<!--==========内容主体结束==========-->
    <script type='text/javascript'>
    //在模板文件中定义的变量会被解析成字符串
    //动态设置js全局变量
    //外部文件都是都是用jquert的$方法进行初始化编
    //程(加载了dom结构)的所以在外部js文件可以找到这些定义的变量
        var address = "{$user.location}";
        //用户星坐
        var constellation = "{$user.constellation}";
        //静态资源路径
        var PUBLIC = '__PUBLIC__';
        var uploadUrl = '{:U("Common/uploadFace")}'
        ;
        //用户sessionid的值
        //用session_id函数输出到js变量中
        var sid = '{:session_id()}';
        //把项目在服务器中的中的根路径
        //如本项目在本地服务器的weibo目录下
        //root值则为/weibo
        var ROOT = '__ROOT__';
    </script>
</body>
</html>
<SCRIPT>
    $('#face').change(function(){
        var a = new FormData();
        a.append("image", $("#face")[0].files[0]);
        a.append("id", 1);
        $.ajax({
            url:uploadUrl,
            xhrFields:{
                    withCredentials:true
            },
            type: "POST",
            cache: false,
            data: a,
            processData: false,
            contentType:false,
            async: false,
            dataType:'json',
            success: function (result) {
                $('#preview').attr('src','/'+result.path.max.split('./')[1])
                $('input[name=face180]').val('/'+result.path.max.split('./')[1])
                $('input[name=face80]').val('/'+result.path.mid.split('./')[1])
                $('input[name=face50]').val('/'+result.path.sma.split('./')[1])
            },
            error:function(error){
                console.log(error)
            }
            //cache 上传文件不需要缓存，所以设置false
            //processData 因为data值是FormData对象，不需要对数据处理
            //contentType 因为是由form表单构造的FormData对象，且已声明了属性enctype，所以为false
        })
    })
</SCRIPT>